package com.cxria.script.upload.domain;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

@Entity
@Table(name = "audioInfo")
class AudioInfo implements Serializable {
    @Id
    @ManyToOne
    @JsonBackReference
    @JoinColumn(name = "videoId")
    Video video;
    @Column
    //@ApiModelProperty("声道数量")
    int channels;
    @Column
    //@ApiModelProperty("时长")
    double duration;
    @Column
    //@ApiModelProperty("档次")
    String profile;
    @Column
    //@ApiModelProperty("采样率")
    int sampleRate;
    @Column
    //@ApiModelProperty("声道布局")
    String channelLayout;
    @Column
    //@ApiModelProperty("样本格式")
    String sampleFormat;
    @Column
    //@ApiModelProperty("位深度")
    int bits;
    @Column
    //@ApiModelProperty("起始时间")
    double startTime;
    @Column
    //@ApiModelProperty("比特率")
    int bitRate;
    @Column
    //@ApiModelProperty("总帧数")
    int frames;
    @Column
    //@ApiModelProperty("音频编解码全名")
    String codecLongName;
    @Column
    //@ApiModelProperty("音频编解码名")
    String codecName;

   

    @Override
    boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AudioInfo audioInfo = (AudioInfo) o;
        return channels == audioInfo.channels &&
                Double.compare(audioInfo.duration, duration) == 0 &&
                sampleRate == audioInfo.sampleRate &&
                bits == audioInfo.bits &&
                Double.compare(audioInfo.startTime, startTime) == 0 &&
                bitRate == audioInfo.bitRate &&
                frames == audioInfo.frames &&
                Objects.equals(video, audioInfo.video) &&
                Objects.equals(profile, audioInfo.profile) &&
                Objects.equals(channelLayout, audioInfo.channelLayout) &&
                Objects.equals(sampleFormat, audioInfo.sampleFormat) &&
                Objects.equals(codecLongName, audioInfo.codecLongName) &&
                Objects.equals(codecName, audioInfo.codecName);
    }

    @Override
    int hashCode() {
        return Objects.hash(video, channels, duration, profile, sampleRate, channelLayout, sampleFormat, bits, startTime, bitRate, frames, codecLongName, codecName);
    }
}
